using AntDesign;
using AntDesign.TableModels;
using SE.PO.CInterface.DBProtocols.AlarmHs;

namespace SE.PO.CInterface.Web.Pages.DB.AlarmH
{
    public partial class AlarmHTable
    {
        #region query

        private bool _loadingData=true;

        private string _searchString;
        
        List<AlarmHDto> _source = new();

        ITable? _table;

        int _pageIndex = 1;
        int _pageSize = 10;
        int _total;

        protected override async Task OnInitializedAsync()
        {
            await GetSourceAsync(_pageIndex, _pageSize);
        }
        public async Task GetSourceAsync(int pageIndex, int pageSize)
        {
            try
            {
                _loadingData = true;
                var skipCount = (pageIndex - 1) * pageSize;
                var result = await Client.GetPage("", skipCount, pageSize);
                if (result != null)
                {
                    _source = result.Items.ToList();
                    _total = result.TotalCount;
                }
            }
            catch (System.Exception ex)
            {
                _ = Notice.Error(new()
                {
                    Duration = 100,
                    Message = "异常",
                    Description = ex.Message
                });
            }
            finally
            {
                _loadingData = false;
            }
        }
        public async Task OnChange(QueryModel<AlarmHDto> queryModel)
        {
            await GetSourceAsync(_pageIndex, _pageSize);
        }
        #endregion
        
    }
}